#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include "dominion/dominion.h"
#include "dominion/dominion_helpers.h"
#include "dominion/rngs.h"
#include "dominion/interface.h"

/* testing adventurer card*/

int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus);

int main (int argc, char * argv[])
{
	/*modified from the initialization in the provided testUpdateCoins.c file */
    int seed = 1000;
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
	int r;
	int bonus = 0;
	
	/* test one -- to see if one card added to hand */
	struct gameState test_one;
    memset(&test_one, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_one); // initialize a new game
	
	test_one.hand[0][0] = village;
	
	int before_handcount = test_one.handCount[0];
	
	cardEffect(village, 0, 0, 0, &test_one, 0, &bonus);
	
	int after_handcount = test_one.handCount[0];
	
	if (after_handcount == before_handcount) //village is discarded and one card added, so should be the same
		printf("Village test: PASS when testing to see if hand count is incremented by 1. \n");
	else
		printf("Village test: FAIL when testing to see if hand count is incremented by 1. \n");
	
	/* test two -- to see if actions are incremented by 2 */
	struct gameState test_two;
    memset(&test_two, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_two); // initialize a new game

	test_two.hand[0][0] = village;
	
	int before_actions = test_two.numActions;
	
	cardEffect(village, 0, 0, 0, &test_two, 0, &bonus);
	
	int after_actions = test_two.numActions;
	
	if (after_actions == (before_actions + 2))
		printf("Village test: PASS when testing to see if actions incremented by 2. \n");
	else
		printf("Village test: FAIL when testing to see if actions incremented by 2. \n");
	
	/* test three -- to see if extra card is still drawn with an empty deck */
	struct gameState test_three;
    memset(&test_three, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_three); // initialize a new game
	
	test_three.hand[0][0] = village;
	test_three.deckCount[0] = 0;
		
	before_handcount = test_three.handCount[0];
	
	cardEffect(village, 0, 0, 0, &test_three, 0, &bonus);
	
	after_handcount = test_three.handCount[0];
	
	if (after_handcount == before_handcount) //village is discarded and one card added, so should be the same
		printf("Village test: PASS when testing to see if hand count is incremented by 1, even when deck is empty. \n");
	else
		printf("Village test: FAIL when testing to see if hand count is incremented by 1, even when deck is empty. \n");	
	
	return 0;
}